package wine.actions;

import wine.logic.entity.WModule;
import wine.web.Struts2Support;

public class WModuleAction extends Struts2Support<WModule> {

	private static final long serialVersionUID = 1L;
	
	/**
	 * 栏目列表
	 * @return
	 */
	public String moduleLst(){
		this.pagedResults = getWModuleDao().findModuleLst(pageInfo);
		this.lst = pagedResults.getResultList();
		this.pageInfo = pagedResults.getPageInfo();
		return SUCCESS;
	}
	
	//验证栏目是否存在
	public String validModuleName(){
		Integer cnt = getWModuleDao().validModuleName(obj);
		if(cnt>0){
			jsonMap.put("isNameExist", Boolean.TRUE);
		}else{
			jsonMap.put("isNameExist", Boolean.FALSE);
		}
		return SUCCESS;
	}
	public String saveModule(){
		jsonMap.clear();
		getWModuleDao().save(obj);
		jsonMap.put("successful", Boolean.TRUE);
		return SUCCESS;
	}
	public String moduleEdit(){
		obj = getWModuleDao().findByPk(obj.getImoduleid());
		return SUCCESS;
	}
	//删除栏目
	public String deleteByImoduleId(){
		jsonMap.clear();
		Integer cnt = getWModuleDao().deleteByImoduleId(obj.getImoduleid());
		jsonMap.put("cnt", cnt);
		return SUCCESS;
	}
}
